package com.gsafety.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class DynamicProxyClient {
    public static void main(String[] args) {
        RealSubject realSubject = new RealSubject();
        InvocationHandler invocationHandler =  new DynamicSubject(realSubject);

        Class<?> classType = invocationHandler.getClass();

        Subject subject = (Subject) Proxy.newProxyInstance(classType.getClassLoader(),
                realSubject.getClass().getInterfaces(),invocationHandler);
        subject.myRequest();

        System.out.println(subject.getClass());
    }
}
